function [ x_low,x_high ] = QMF_Filtering( x )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
%Design QMF FIR filters
N = 99;
[H0,H1,G0,G1] = firpr2chfb(N,0.49);

% Analysis filters (decimators).
Hlp = mfilt.firdecim(2,H0);
Hhp = mfilt.firdecim(2,H1);

% Synthesis filters (interpolators).
Glp = mfilt.firinterp(2,G0);
Ghp = mfilt.firinterp(2,G1);

% % %analysis
% % hfv = fvtool(Hlp);
% % legend(hfv,'Hlp Lowpass Decimator');
% % set(hfv, 'Color', [1 1 1])
% % 
% % % look at all four filters
% % set(hfv, 'Filters', [Hlp,Hhp,Glp,Ghp]);
% % legend(hfv,'Hlp Lowpass Decimator','Hhp Highpass Decimator',...
% %     'Glp Lowpass Interpolator','Ghp Highpass Interpolator');

%% filter the data
[rows cols ] = size(x);
x_low=[];
x_high=[];
filter_len = length(H0);
for r=1:rows
    xr=[x(r,:), zeros(1,filter_len)];
    
    % Lowpass frequency band.
    x0 = filter(Hlp,xr);       % Analysis filter bank output
    x0 = filter(Glp,x0);      % Synthesis filter bank output

    % High frequency band.
    x1 = filter(Hhp,xr);       % Analysis filter bank output
    x1 = filter(Ghp,x1);      % Synthesis filter bank output

    % xtilde = x0+x1;

    x_low(r,:)=x0(filter_len+2:end);
    x_high(r,:)=x1(filter_len+2:end);
end

end

